package com.guli.generator.service.impl;



import com.guli.generator.mapper.EduCourseDescriptionMapper;
import com.guli.generator.mapper.EduCourseMapper;
import com.guli.generator.pojo.EduCourse;
import com.guli.generator.pojo.EduCourseDescription;
import com.guli.generator.pojo.vo.CourseInfoVo;
import com.guli.generator.service.EduCourseService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author Administrator
* @description 针对表【edu_course(课程)】的数据库操作Service实现
* @createDate 2021-12-28 20:25:55
*/
@Service
public class EduCourseServiceImpl implements EduCourseService {
    @Resource
    private EduCourseMapper courseMapper;
    @Resource
    private EduCourseDescriptionMapper mapper;
    @Override
    public Integer addCourse(CourseInfoVo courseInfoVo) {
        //获取课程对象
        EduCourse course = new EduCourse();
        //将courseInfoVo工具对象复制给course
        BeanUtils.copyProperties(courseInfoVo,course);
        //添加数据库
        int insert = courseMapper.insert(course);
        //获取课程详细对象
        EduCourseDescription courseDescription = new EduCourseDescription();
        //赋值
        courseDescription.setId(courseInfoVo.getId());
        courseDescription.setDescription(courseInfoVo.getDescription());
        //添加数据库
        int insert1 = mapper.insert(courseDescription);
        Integer count = insert1+insert;
        return count;
    }
}
